home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / bbsutil / hsrc_117.zip / CVRTSTRG.C < prev    next >
C/C++ Source or Header  |  1990-08-21  |  2KB  |  87 lines

  1. #include "msgg.h"
  2. #include "twindow.h"
  3. #include "headedit.h"
  4.  
  5.  
  6. /* Expand metastrings in passed string */
  7.  
  8. char * pascal convertstring (char *a) { /* Not reentrant */
  9.  
  10.  char arg=0;
  11.  char *pp;
  12.  char *p;
  13.  char strr[256];
  14.  char cvstr[364];
  15.  char middle[82];
  16.  
  17.    strset(strr,0);
  18.    strset(cvstr,0);
  19.    strcpy(strr,a);
  20.    p=strr;
  21.    pp=cvstr;
  22.    while(*p) {
  23.         if (*p=='*' && p[1]) {
  24.            arg=p[1];
  25.            p+=2;
  26.            switch ((int)arg) {
  27.              case 'F':    /* From Name */
  28.                           strcpy(middle,msg.from);
  29.                           turn_spaces_to_uls(middle);
  30.                           strcat(pp,middle);
  31.                           break;
  32.              case 'f':      strcat(p,msg.from);
  33.                           break;
  34.              case 'T':      /* To Name */
  35.                           strcpy(middle,msg.to);
  36.                           turn_spaces_to_uls(middle);
  37.                           strcat(pp,middle);
  38.                           break;
  39.              case 't':      strcat(pp,msg.to);
  40.                           break;
  41.              case 'd':      strcat(pp,msg.date);
  42.                           break;
  43.              case 'D':      /* Msg Date */
  44.                           strcpy(middle,msg.date);
  45.                           turn_spaces_to_uls(middle);
  46.                           strcat(pp,middle);
  47.                           break;
  48.              case 'N':      strcat(pp,currarea->name);
  49.                           break;
  50.              case 'A':    /* Area Name */
  51.                           strcpy(middle,currarea->name);
  52.                           turn_spaces_to_uls(middle);
  53.                           strcat(pp,middle);
  54.                           break;
  55.              case '#':      sprintf(middle,"%u",messno);
  56.                           strcat(pp,middle);
  57.                           break;
  58.              case 'a':      sprintf(middle,"%u",areano);
  59.                           strcat(pp,middle);
  60.                           break;
  61.              case 'P':      strcat(pp,path);
  62.                           break;
  63.              default:     strcat(pp,"*");
  64.                           p--;
  65.                           break;
  66.            }
  67.         }
  68.         else {
  69.             *pp=*p;
  70.             pp[1]=0;
  71.             p++;
  72.         }
  73.         while(*pp)pp++;
  74.    }
  75.    return (cvstr);
  76. }
  77.  
  78.  
  79.  
  80. void pascal turn_spaces_to_uls (char *a) {
  81.  
  82.     char *p;
  83.  
  84.     while (p=strchr(a,' ')) *p='_';
  85. }
  86.  
  87.